package com.xindaoapp.happypet.activity;

import android.annotation.SuppressLint;
import android.net.Uri;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;

import com.xindaoapp.happypet.R;
import com.xindaoapp.happypet.view.MyTestVideoView;
import com.xindaoapp.happypet.view.PullToRefreshListView;

public class MainVideoActivity extends UMBaseActivity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.layout_video);
        PullToRefreshListView listView = ((PullToRefreshListView) findViewById(R.id.listview));
        listView.addHeaderView(getHeaderView2());
        listView.setAdapter(new T());
        findViewById(R.id.loading).setVisibility(View.GONE);
    }

    @SuppressLint("NewApi")
    private View getHeaderView2() {
        View view = LayoutInflater.from(getBaseContext()).inflate(R.layout.item_video2, null);
        MyTestVideoView my = (MyTestVideoView) view.findViewById(R.id.surfaceView);

        DisplayMetrics displaymetrics = new DisplayMetrics();
        getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
        LinearLayout.LayoutParams layoutParams =
                new LinearLayout.LayoutParams(displaymetrics.widthPixels,
                        displaymetrics.widthPixels);
        my.setLayoutParams(layoutParams);
        my.initVideoView();
        my.setVideoURI(Uri
                .parse("http://bbs.chinapet.com/source/plugin/leepet_thread/upload/201406/01/20140601102835538a8fd3d2fea.mp4"));
        // my.openVideo();
        return view;
    }

    class T extends BaseAdapter {

        @Override
        public int getCount() {
            return 0;
        }

        @Override
        public Object getItem(int position) {
            return null;
        }

        @Override
        public long getItemId(int position) {
            return 0;
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            View view = LayoutInflater.from(getBaseContext()).inflate(R.layout.item_video, null);
            return view;
        }

    }

}
